//
//  JUMeVC.m
//  findFriend
//
//  Created by ju on 14-9-11.
//  Copyright (c) 2014年 dono. All rights reserved.
//

#import "JUMeVC.h"
#import <AVOSCloud/AVOSCloud.h>
#import "JUChatListVC.h"
#import "JUAppDelegate.h"
#import "JWCSettingCell.h"
#import "JWCSettingCellItem.h"

@interface JUMeVC ()
{
    UILabel *_usernameLabel;
}

@end

@implementation JUMeVC

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title = @"我";
    [self setupSection0];
//    [self setupLabel];
//    [self setupBtn];
}

#pragma mark 初始化显示用户名的label
- (void)setupLabel
{
    _usernameLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 180, 280, 80)];
    _usernameLabel.textAlignment = NSTextAlignmentCenter;
    _usernameLabel.font = [UIFont systemFontOfSize:40];
    _usernameLabel.text = [AVUser currentUser].username;
    [self.view addSubview:_usernameLabel];
}

#pragma mark 初始化注销button
- (void)setupBtn
{
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(20, 300, 280, 80);
    [button setTitle:@"退出登录" forState:UIControlStateNormal];
    button.titleLabel.textAlignment = NSTextAlignmentCenter;
    button.titleLabel.font = [UIFont systemFontOfSize:18];
    [button addTarget:self action:@selector(logOut) forControlEvents:UIControlEventTouchUpInside];
    button.backgroundColor = [UIColor orangeColor];
    button.titleLabel.textColor = [UIColor whiteColor];
    [self.view addSubview:button];
}

- (void)logOut
{
    [AVUser logOut];
    JUAppDelegate *delegate = [UIApplication sharedApplication].delegate;
    [delegate showLogin];
    
}

- (void)setupSection0
{
    JWCSettingCellItem *profile = [[JWCSettingCellItem alloc] init];
    profile.style = JWCSettingCellItemStyleArraw;
    profile.title = @"好友";
//    profile.willShowClass = [MGViewPersonalTVC class];
    
    JWCSettingCellItem *hotelOrder = [[JWCSettingCellItem alloc] init];
    hotelOrder.style = JWCSettingCellItemStyleArraw;
    hotelOrder.title = @"收藏";
//    hotelOrder.willShowClass = [MGOrderListsVC class];
    
    JWCSettingCellItem *ruralOrder = [[JWCSettingCellItem alloc] init];
    ruralOrder.style = JWCSettingCellItemStyleArraw;
    ruralOrder.title = @"足迹";
//    ruralOrder.willShowClass = [MGRuralOrderList class];
    
    JWCSettingCellItem *travelNotes = [[JWCSettingCellItem alloc] init];
    travelNotes.style = JWCSettingCellItemStyleArraw;
    travelNotes.title = @"贡献";
//    travelNotes.willShowClass = [MGMyTravelNotesVC class];
    
    
    JWCSettingCellItem *setting = [[JWCSettingCellItem alloc] init];
    setting.style = JWCSettingCellItemStyleArraw;
    setting.title = @"设置";
//    setting.willShowClass = [MGSettingViewController class];
    
    JWCSection *sectionGroup = [[JWCSection alloc] init];
    sectionGroup.items = @[profile,hotelOrder,ruralOrder,travelNotes,setting];
    
    [_allGroup addObject:sectionGroup];
    
    
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
    UIView *footerView = [[UIView alloc] init];
    footerView.backgroundColor = [UIColor clearColor];
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(0, 10, 320, 50);
    [button setTitle:@"退出登录" forState:UIControlStateNormal];
    button.titleLabel.textAlignment = NSTextAlignmentCenter;
    button.titleLabel.font = [UIFont systemFontOfSize:20];
    [button addTarget:self action:@selector(logOut) forControlEvents:UIControlEventTouchUpInside];
    button.layer.cornerRadius = 5;
    [button clipsToBounds];
    button.backgroundColor = [UIColor orangeColor];
    button.titleLabel.textColor = [UIColor whiteColor];
    [footerView addSubview:button];
    return footerView;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 70.0f;
}

@end
